package juc.lock;

import java.util.concurrent.TimeUnit;


public class Test4 {

    public static void main(String[] args) {
        // 静态方法锁的是 当前类
        Phone1 phone = new Phone1();
        Phone1 phone1 = new Phone1();

        new Thread(()->{
            phone.sendMsg();
        },"a").start();
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(()->{
            phone1.call();
        },"b").start();
    }


}
class Phone1 {
    public  static synchronized  void sendMsg() {
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("发短信");
    }

    public static synchronized void call() {
        System.out.println("打电话");
    }


}

